package bean生命周期.main.java.com.itheima.service.impl;

import com.itheima.dao.BookDao;
import com.itheima.service.BookService;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class BookServiceImpl implements BookService ,InitializingBean,DisposableBean {
    private BookDao bookDao;

    public void setBookDao(BookDao bookDao) {
        System.out.println("set .....");
        this.bookDao = bookDao;
    }

    public void save() {
        System.out.println("book service save ...");
        bookDao.save();
    }

    /**
     * bean销毁方法
     * @throws Exception
     */
    @Override
    public void destroy() throws Exception {
        System.out.println("service destroy...");
    }

    /**
     * set之后就是sql注入之后执行的方法
     * @throws Exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("service init ...");
    }
}
